import { AttributeType } from './AttributeType';

export class AttributeDependency {
    private dependencies: Map<AttributeType, Set<AttributeType>>;

    constructor() {
        this.dependencies = new Map();
    }

    public addDependency(source: AttributeType, target: AttributeType): void {
        if (!this.dependencies.has(source)) {
            this.dependencies.set(source, new Set());
        }
        this.dependencies.get(source)!.add(target);
    }

    public removeDependency(source: AttributeType, target: AttributeType): void {
        const targets = this.dependencies.get(source);
        if (targets) {
            targets.delete(target);
            if (targets.size === 0) {
                this.dependencies.delete(source);
            }
        }
    }

    public getDependentAttributes(source: AttributeType): Set<AttributeType> {
        return this.dependencies.get(source) || new Set();
    }
} 